<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="keywords.list.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
</head>
<body>
<div id="wrapper">
<div id="main_box">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/welcome.action"><s:text name="homepage"/></a><span>></span><s:text name="keywords.title"/></div>
	<div class="listtit" id="listtit"><p><span><strong><s:text name="keywords.list.title"/></strong></span></p></div>
	<s:form action="keywords-list" id="search_form">
	<div class="searchbox">
		<label for="search" class="labelKeywords"><s:text name="key.words"/>:</label>
		<s:textfield id="search" name="keywords.kword" cssClass="txtsearch_long" maxlength="30"  />
		<input type="button" value="<s:text name="query"/>" class="btnsearch" id="search_btn"/>
		<div class="clear"></div>
	</div>
	 
	<div class="listoperate">
		<span class="cssa"><input id="top_new_btn" type="button" value="<s:text name="new"/>" class="btnadd"/></span>
		<span>
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="top_anti_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="top_del_btn"/>
		</span>
	</div>
	<div class="listbox" id="listbox">
		 
		<table class="listgrid" id="listbox">
			<tbody>
				<tr>
					<th><input type="checkbox" name="all" id="all_check"/></th>
					<th><s:text name="keywords.keywords"/></th>
					<th><s:text name="keywords.firstLetter"/></th>
					<th><s:text name="keywords.pinyin"/></th>					
					<th><s:text name="keywords.splitWords"/></th>										
					<th><s:text name="keywords.isenable"/></th>

					<th><s:text name="operate"/></th>
				</tr>
				<s:iterator value="page.result">
					<tr>
						<td><input type="checkbox" name="key" value="<s:property value="keywordsId"/>"/></td>
					<td><s:property value="keywords"/>&nbsp;</td>
					<td><s:property value="firstLetter"/>&nbsp;</td>
					<td><s:property value="pinyin"/>&nbsp;</td>
					<td><s:property value="splitWords"/>&nbsp;</td>
					<td>
					<s:if test="isEnable">
						已启用
					</s:if>
					<s:else>
						<font style="color:#FF0000">已禁用</font>
					</s:else>
					</td>
					<td>
						<a href="keywordsrecommend-input.action?keywordsRecommend.keywords.keywordsId=<s:property value="keywordsId"/>">推荐信息</a><tt>|</tt>
						<s:if test="isEnable">
							<a href="#this" onclick="changeEnable('<s:property value="keywordsId"/>')">禁用</a><tt>|</tt>
						</s:if>
						<s:else>
							<a href="#this" onclick="changeEnable('<s:property value="keywordsId"/>')">启用</a><tt>|</tt>
						</s:else>
						<a href="#this" onclick="goEdit('keywords.keywordsId','<s:property value="keywordsId"/>')"><s:text name="edit"/></a><tt>|</tt>
					    <a href="#this" onclick="goDel('<s:property value="keywordsId"/>')"><s:text name="delete"/></a>
					</td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
	</div>
	<div class="listoperateb h33">
		<span class="fl">
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="bottom_anti_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="bottom_del_btn"/>
		</span>
		<div class="pager fr"><z:page numberNav="true" selectPageSize="true" input="true" id="ctrl"/></div>
	</div>
		</s:form>
</div>
</div>
</body>
</html>
<script type="text/javascript" defer="defer">
	actionName = "keywords";	
	confirmStr = "<s:text name="delete.confirm"/>";
	chiocenothing = "<s:text name="chiocenothing"/>";
	$(function(){
 		$("#top_new_btn").click(goNew);
 		$("#top_anti_btn").click(antiSelect);
 		$("#top_del_btn").click(doBatchDel);
 		$("#bottom_del_btn").click(doBatchDel);
 		$("#bottom_anti_btn").click(antiSelect);
		$("#search_btn").click(search);
		$("#all_check").click(selAll);
		$("#extend").click(extend);
		$("#search_btn").click(function(){
			$("#ctrl_page_input").val(1)
		});
	});
	
	function changeEnable(id){
		$.ajax({
			type:"POST",
			async:false,
			url:"keywords-changeEnable.action?random="+Math.random(),
			data:{'keywords.keywordsId':id},
			success:function(data){
				alert(data);
				go();
			}
		});
	}
	$(function(){
		if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
			$('#main_box').width($('#main_box').width()-25);
		}
	});
	
	function doBatchDel(){
		var arr = allSelected();
		
		$.ajax({
			url:"keywords-delete-ajax.action?random="+Math.random(),
			data:$.param({key:arr},true),
			type:'post',
			dataType:'text',
			success:function(d){
				var json = eval('('+d+')');
				alert(json.msg);
				if(json.flag){
					window.location.reload(true);
				}
			}
		});
	}
	
	function allSelected(){		 
		var ids = new Array(); 
		$("input[name=key]:checked").each(function(i,item){
			ids.push($(item).val());	 
		 });
		return ids;		
	}
	</script>